%macro get_f1099g;


	proc printto new log = "&logdir./get_f1099g.txt";
	run;


	/****************************************************
	*			Put individuals into a tinlist			*
	****************************************************/
	%make_tinlist;


	
				proc sql noprint;
				[connection details redacted]
					create table sample as
					select * from connection to iq 
					(
					select distinct
						a.[redacted] as person_id,
						a.[redacted] as ui,
						a.[redacted] as f1099g_ref,
						a.[redacted] as wh
					from [redacted] as a
						inner join #tinlist as b
							on(a.[redacted] = b.person_id)
					where a.[redacted] = &base_yr
						and a.[redacted]<=4
					);
				disconnect from iq;
				quit;



		/****************************
		*		Take a proc sum		*
		****************************/
		proc means data = sample nway noprint;
			class person_id;
			output out = rlib.f1099g(drop=_type_ _freq_)
				sum(ui f1099g_ref wh) = 
					ui f1099g_ref f1099g_wh;
	

	proc printto;
	run;

	


%mend;
